<?php

use yii\helpers\Html;
//use yii\grid\GridView;
use backend\models\EduUser;
use dosamigos\datepicker\DatePicker;
use kartik\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\EduUserSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '用户管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="edu-user-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>

    <p>
        <!--        --><? //= Html::a('Create Edu User', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'pager' => [
            'firstPageLabel' => '首页',
            'lastPageLabel' => '尾页',

        ],
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],

            'id',
            [
                'attribute' => 'avatar_url',
                'enableSorting' => false,
                'format' => ['image', [
                    'width' => '80',
                    'height' => '80',
                ]],
            ],
//            'openid',
            [
                'attribute' => 'openid',
                'enableSorting' => false,
            ],
//            'nickname',
            [
                'attribute' => 'nickname',
                'enableSorting' => false,
            ],
//            'avatar_url:url',
//            'sex',
            [
                'attribute' => 'sex',
                'enableSorting' => false,
                'value' => 'sexValue',
                'filter' => EduUser::attributeValue()['sex']
            ],
            //'city',
            //'country',
            //'province',
//            'phone',
            [
                'attribute' => 'phone',
                'enableSorting' => false,
            ],
            //'address',
//            'is_teach',
            [
                'attribute' => 'is_teach',
                'enableSorting' => false,
                'value' => 'isTeach',
                'filter' => EduUser::attributeValue()['is_teach']
            ],
            [
                'attribute' => 'mall_is',
                'enableSorting' => false,
                'value' => 'MallIs',
                'filter' => EduUser::attributeValue()['mall_is']
            ],
            [
                'attribute' => 'mall_id',
                'enableSorting' => false,
                'value' => 'mall_id',
                'filter' => EduUser::getMall()
            ],
            [
                'attribute' => 'mall_superior',
                'enableSorting' => false,
                'format' => 'raw',
                'value' => function ($model) {
                    return $model->mall_superior . '-' . Html::a('上级', ['edu-user/index', 'EduUserSearch[id]' => $model->mall_superior], ['class' => '']);
                }
            ],
            [
                'attribute' => 'mall_top',
                'enableSorting' => false,
            ],
            'score',
            'score_total',
            'recharge',
            "mall_total_fee",
            'mall_appear_fee',
            //'is_red',
            [
                'attribute' => 'is_red',
                'enableSorting' => false,
                'value' => 'IsRed',
                'filter' => EduUser::attributeValue()['is_red'],
            ],
            //'info',
//            'status',
//            [
//                'attribute' => 'status',
//                'enableSorting' => false,
//                'value' => 'statusValue',
//                'filter' => EduUser::attributeValue()['status']
//            ],
//            'create_time:datetime',
            [
                'attribute' => 'create_time',
                'value' => function ($model, $key, $index) {
                    return date('Y-m-d', $model->create_time);
                },
                'filter' => DatePicker::widget([
                    'model' => $searchModel,
                    'attribute' => 'create_time',
                    'language' => 'zh-CN',
                    'clientOptions' => [
                        'autoclose' => true,
                        'format' => 'yyyy-mm-dd'
                    ]
                ]),
            ],
            //'update_time:datetime',
            //'parent_id',

            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
</div>
<?php
$script = <<< JS
    $(".pagination").append('&nbsp;跳转<input id="invalue" type="text" style="border-radius: 5px;outline: none;border: solid 1px #dddddd;width: 52px;height: 34px;text-align: center;" class="pane"/>页&nbsp;<button id="skip" class="btn btn-default skip ok"">确定</button>');
    
    $('#skip').click(function() {
        var page = $('#invalue').val();
        location.href = "index.php?r=edu-user/index&page="+ page;
    });
JS;
$this->registerJs($script);
?>

